//****************************************************************/
//Creation History
// Company: GZ office
// NAME:    CostCenterSearch.java
// TITLE:   Cost Center Column Accessibility Maintenance
// BY:      Oscar Bai
// DATE:    03/03/2003
//******************************************************************/
//Modification History
//******************************************************************/
// CR 1347  Miranda Lin  11-Aug-2004
// ADD: added division id
//******************************************************************/



package admin.system.costcenter;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.servlet.*;
import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;

public class CostCenterSearch
  extends DBServlet {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      CostCenterBean costCenter = CostCenterProcess.createBean();
      costCenter.setCost_Center_id(request.getParameter("cost_center_id"));
      costCenter.setCost_Center_name(request.getParameter("cost_center_name"));
      costCenter.setCost_Center_des(request.getParameter("cost_center_des"));
/* CR 1347 */
      costCenter.setDivision_id(request.getParameter("division_id"));
/* CR 1347 */
      CostCenterBean[] costCenters = CostCenterProcess.find(this.getConnection(),costCenter);
      if (costCenters==null || costCenters.length==0)
      {
          message.setMessage("No record, please input another criteria.");
          return "system/CostCenterSearch.jsp";
      }
      else if (costCenters.length==1)
      {
          request.setAttribute("costCenters",costCenters[0]);
          return "system/CostCenter.jsp?formAction=Update";
      }
      else
      {
          request.setAttribute("costCenters",costCenters);
          return "system/CostCenterList.jsp";
      }
  }
}


